keyboard messages
Keyboard messages contain the window number of the window that was selected when the keyboard event was detected. v0,v1,v2,v3 contain xWin,yWin,state,time.

keyboard focus
Window functions generally convert WindowKeyDown and WindowKeyUp messages into equivalent grid messages KeyDown and KeyUp and send them to the grid that currently has keyboard focus.

Window functions generally move keyboard focus from grid to grid in response to Alt+LeftArrow and Alt+RightArrow keystrokes.

xWin, yWin
xWin,yWin may the position of the mouse cursor in the window coordinates of the selected window at the time the keyboard event was detected. If xWin or yWin is negative, the mouse cursor was outside the selected window, or the position of the mouse was unavailable.

state
state contains the state of the keyboard when the keyboard event was detected, and reflects the new state of the keyboard.

Bit 00 - 15 : Character code of some kind (see bits 20-22)
Bit 16 - 23 : Keyboard "mode" keys (16=Shift, 17=Control, 18=Alt)
Bit 24 - 31 : Virtual Key Code

Bit 16 = 1  : Shift key was down when the keyboard event occured.
Bit 17 = 1  : Control key was down when the keyboard event occured.
Bit 18 = 1  : Alt key was down when the keyboard event occured.
Bit 19      : Reserved
Bit 20 - 22 : Type of character code in Bit 00 - 15 (see below)
Bit 20 - 22 : 0 = Bit 00 - 15 = Virtual Key Code (8-bits)
            : 1 = Bit 00 - 15 = ASCII character (8-bits)
            : 2 = Bit 00 - 15 = WIDE character (16-bits)
            : values 3 to 7 are reserved

time
time contains the system time that the keyboard event was detected. time is not related to time of day. time is a free running millisecond timer that computer systems usually initialize to zero when they start.

examples
Key    20-22 18 17 16 0-15  "."   mode key states, key event
Down     1   0  0  0   97    a    None down, "a" down
Up       0   0  0  0   97    -    None down, "a" up
Down     1   0  0  1   65    A    Shift down, "a" down
Up       0   0  0  1   65    -    Shift down, "a" up
Down     0   0  1  0   65   ^A    Ctl down, "a" down
Down     0   0  1  1   65    ?    Ctl+Shift down, "a" down
Down     0   1  0  0   65    ?    Alt down, "a" down
Down     0   1  0  1   65    ?    Alt+Shift down, "a" down
Down     0   1  1  0   65    ?    Alt+Ctl down, "a" down
Down     0   1  1  1   65    ?    Alt+Ctl+Shift down, "a" down
Up       0   1  1  1   65    ?    Alt+Ctl+Shift down, "a" up
Down     0   0  1  0   39   Left  Ctl down, LeftArrow press

WindowKeyUp vs WindowKeyDown
Most programs respond only to WindowKeyDown messages, since that is sufficient to respond to all keystrokes. WindowKeyDown messages are created at a rate of about 10 per second when a key is held down, followed by a single WindowKeyUp when the key is finally released.